package com.weayer.controller;

import com.weayer.dto.Car;
import com.weayer.dto.DriverCarBindingRelationship;
import com.weayer.dto.DriverUser;
import com.weayer.dto.ResponseResult;
import com.weayer.service.DriverUserService;
import lombok.extern.slf4j.Slf4j;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description: Api服务 - BOSS - 司机以及车辆管理Controller
 * @author: Weayer
 **/
@RestController
@Slf4j
public class DriverUserController {
    @Autowired
    private DriverUserService driverUserService;

    @PostMapping("/driver-user")
    public ResponseResult addDriverUser(@RequestBody DriverUser driverUser){
        log.info(JSONObject.fromObject(driverUser).toString());
        return driverUserService.addDriverUser(driverUser);
    }
    @PutMapping("/driver-user")
    public ResponseResult updateDriverUser(@RequestBody DriverUser driverUser){
        return driverUserService.updateDriverUser(driverUser);
    }
    @PostMapping("/car")
    public ResponseResult addCar(@RequestBody Car car){
        return driverUserService.addCar(car);
    }
    @PutMapping("/car")
    public ResponseResult updateCar(@RequestBody Car car){
        return driverUserService.updateCar(car);
    }
    @PostMapping("/driver-car-binding-relationship/bind")
    public ResponseResult bind(@RequestBody DriverCarBindingRelationship driverCarBindingRelationship){
        return driverUserService.bind(driverCarBindingRelationship);
    }
    @PostMapping("/driver-car-binding-relationship/unbind")
    public ResponseResult unbind(@RequestBody DriverCarBindingRelationship driverCarBindingRelationship){
        return driverUserService.unbind(driverCarBindingRelationship);
    }
}
